using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Dal.Entities;

namespace Dal.Mapping
{
	public class MessageMap : EntityTypeConfiguration<Message>
	{
		public MessageMap()
		{
			// Primary Key
			this.HasKey(t => t.ID);

			// Properties
			this.Property(t => t.MsgContent)
				.IsRequired()
				.HasMaxLength(500);
				
			this.Property(t => t.ReplyContent)
				.HasMaxLength(500);
				
			// Table & Column Mappings
			this.ToTable("Message");
			this.Property(t => t.ID).HasColumnName("ID");
			this.Property(t => t.SenderUserID).HasColumnName("SenderUserID");
			this.Property(t => t.MsgContent).HasColumnName("MsgContent");
			this.Property(t => t.ReplyContent).HasColumnName("ReplyContent");
			this.Property(t => t.AddTime).HasColumnName("AddTime");
			this.Property(t => t.ReplyTime).HasColumnName("ReplyTime");
			this.Property(t => t.FlagDelete).HasColumnName("FlagDelete");
		}
	}
}

